basedir <- '/data/projects/pro42/r-nitools'
if (getwd() != basedir)
    stop('Must be in directory: ', basedir)
source("neuroimage.R")

funcnames <- as.character(as.matrix(read.table("../z_funclist_8mm.txt")))
maskname <- "/data/projects/pro42/masks/lfo_mask_8mm.nii.gz"

# Test reading nifti info
x <- read.nifti(funcnames[1])
x <- read.nifti.header(funcnames[1])

# Test read 4D and 2D
x1 <- read.nifti.old(funcnames[1])
x2 <- read.nifti(funcnames[1])
x3 <- read.nifti2mat(funcnames[1])

all(apply(cbind(x1[1,1,1,], x3[,1]), 1, function(x) x[1]==x[2]))
all(apply(cbind(x1[9,22,8,], x3[,5000]), 1, function(x) x[1]==x[2]))

# Test out batch loading
xs <- batch.nifti2matrix(funcnames, maskname)